package suites.queue {
	import suites.queue.mock.AsyncQable;
	import suites.queue.mock.ImmediateQable;

	import org.flexunit.asserts.assertEquals;
	import org.flexunit.asserts.assertNotNull;

	/**
	 * @author Max Kugland
	 */
	public class QBasicTest extends AbstractQTest {

		[Test(async)]
		public function empty() : void {
			handleAsync(200);
			_q.start();
		}
		
		[Test]
		public function testGetById() : void {
			_q.add(new AsyncQable("1"));
			_q.add(new AsyncQable("2"));
			_q.add(new AsyncQable("3"));
			assertNotNull(_q.getForId("1"));			assertNotNull(_q.getForId("2"));			assertNotNull(_q.getForId("3"));
		}
		
		[Test(async)]
		public function oneImmediate() : void {
			handleAsync(200);
			_q.add(new ImmediateQable("1"));
			assertEquals(1, _q.length);
			_q.start();
		}
		
		[Test(async)]
		public function threeImmediate() : void {
			handleAsync(200);
			_q.add(new ImmediateQable("1"));
			_q.add(new ImmediateQable("2"));
			_q.add(new ImmediateQable("3"));
			assertEquals(3, _q.length);
			_q.start();
		}
		
		[Test(async)]
		public function oneAsync() : void {
			handleAsync(500);
			_q.add(new AsyncQable("1"));
			assertEquals(1, _q.length);
			_q.start();
		}
		
		[Test(async)]
		public function threeAsync() : void {
			handleAsync(1000);
			_q.add(new AsyncQable("1"));
			_q.add(new AsyncQable("2"));
			_q.add(new AsyncQable("3"));
			assertEquals(3, _q.length);
			_q.start();
		}
		
		[Test(async)]
		public function mixedImmediateAsync() : void {
			handleAsync(1000);
			_q.add(new AsyncQable("1"));
			_q.add(new ImmediateQable("2"));
			_q.add(new ImmediateQable("3"));
			_q.add(new AsyncQable("4"));
			_q.add(new ImmediateQable("5"));
			_q.add(new AsyncQable("6"));
			assertEquals(6, _q.length);
			_q.start();
		}
	}
}
